/* 
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */



function cargarDatosIniciales(){
   
    //---------------------------------//
    //   MARCADOR AL HACER CLICK
    //---------------------------------//
    GEvent.addListener(map, "click", function(marker, point) {
        if (marker) {
            return null;
        } else {
            //map.setCenter(point);
            map.clearOverlays();
            var marcador = new GMarker(point);
            map.addOverlay(marcador);
            
            for (i = 0; i < document.forms.length; i++) {                
                if(document.forms[i].name.lastIndexOf("formMapa")>0){
                    var v =document.forms[i];
                    for (j = 0; j < v.elements.length; j++) {
                        if(v[j].name.lastIndexOf("mmLongitud")>0){
                            var v1 = v[j];
                            v1.value=point.x;
                        }
                        if(v[j].name.lastIndexOf("mmLatitud")>0){
                            var v2 = v[j];
                            v2.value=point.y;
                        }
                    }
                }
                    
            
            }
           
        //document.form_mapa.coordenadas.value = point.y+","+point.x;
        }
    }
    );
    //---------------------------------//
    //   FIN MARCADOR AL HACER CLICK
    //---------------------------------//
    function placeMarker(location) {
        var clickedLocation = new google.maps.LatLng(location);
        //map.clearOverlays();
        document.form1.x.value = location.lat();
        document.form1.y.value = location.lng();
        //alert(document.form1.x.value);
        //alert(location.lat()+' '+location.lng());
        var marker = new google.maps.Marker({
            position: location,
            map: map
        });

        map.setCenter(location);
    }
    function placeMarker1(x,y) {


        alert(x);
        var point = new GLatLng(x, y)
        map.setCenter(point, zoom);
        alert(point);
        var clickedLocation = new google.maps.LatLng(point);
        //map.clearOverlays();
        //        document.form1.x.value = x;
        //        document.form1.y.value = location.y;
        //alert(document.form1.x.value);
        //alert(location.lat()+' '+location.lng());
        var marker = new google.maps.Marker({
            position: point,
            map: map
        });

        map.setCenter(point);
    }
}
